Due to the 3A algorithms (autofocus, auto-exposure, auto white-balancing) that are required for a well-exposed, focused and white-balanced picture, the “lead time” to take pictures can be annoyingly long (especially for moving children or animals). Since any system needs photons to work, in the dark or under low-light conditions an autofocus system may require additional light. However, a long or continuous pre-flash light is often not wanted. IR autofocus has been developed for these cases. Unfortunately, such IR autofocus systems need an additional sensor and generally work only at one or selected points of the image, rather than over the complete image. It would be desirable to obtain a compact autofocus system with a reduced number of components providing a reliable autofocus function even under low light conditions considering the complete image.